<?php
namespace app\index\controller;
use think\Controller;
use app\index\Model\Line;
class Index extends Allow
{
    public function index()
    {

//        $data = Line::get(1);
//        dump($data);
//        $content = file_get_contents('./01.txt',1,null,0,10000000);
//        $data = explode('。',$content);
//        dump($content);
//        return view("index");
    }

    /*public function piecewise($number){
        $content = file_get_contents('./01.txt',1,null,0,10000000);
        $data = explode('。',$content);
        if(strlen($data[$number])<=6){
            return $data[$number-1];
        }
        return $data[$number];
    }

    public function setInterVal(){
        $content = file_get_contents('./01.txt',1,null,0,10000000);
        $data = explode('。',$content);
        $number = count($data);
        return view('setInterval',['number' => 363]);
    }
    public function postSetInterVal(){
        $number = $_POST['number'];
        $data_length = $this->piecewise($number);
        if(empty($data_length))return false;
        $data_comma = $this->wipeOut($data_length);
        $this->explodeString($data_comma);
        return $number;
    }
    public function explodeString($data_comma){
        $char = "。、！？，";
        $arr = preg_split('/['.$char.']/u', $data_comma);
        $length = count($arr);
        for($i=0;$i<=$length-1;$i++){
            db('line')->insert(['content' => $arr[$i],'created_at' => date('Y-m-d H:i:s',time())]);
        }
    }
    public function wipeOut($str){
        $char = "“”";
        $pattern = array(
            "/[[:punct:]]/i", //英文标点符号
            '/['.$char.']/u', //中文标点符号
            '/[ ]{2,}/'
        );
        $str = preg_replace($pattern, ' ', $str);
        return $str;
    }
    public function punctuation($string){
        $char = "。、！？：；﹑•＂…‘’“”〝〞∕¦‖—　〈〉﹞﹝「」‹›〖〗】【»«』『〕〔》《﹐¸﹕︰﹔！¡？¿﹖﹌﹏﹋＇´ˊˋ―﹫︳︴¯＿￣﹢﹦﹤‐­˜﹟﹩﹠﹪﹡﹨﹍﹉﹎﹊ˇ︵︶︷︸︹︿﹀︺︽︾ˉ﹁﹂﹃﹄︻︼（）";
        $pattern = array(
            "/[[:punct:]]/i", //英文标点符号
            '/['.$char.']/u', //中文标点符号
            '/[ ]{2,}/'
        );
        $str = preg_replace($pattern, ' ', $string);
        return $str;
    }
    public function ceshi(){
        $data_length = $this->piecewise(130);
        if(empty($data_length))return false;
        $data_comma = $this->wipeOut($data_length);
        $char = "。、！？，";
        $arr = preg_split('/['.$char.']/u', $data_comma);
        $length = count($arr);
        for($i=0;$i<=$length-1;$i++){
//            db('line')->insert(['content' => $arr[$i],'created_at' => date('Y-m-d H:i:s',time())]);
            dump($arr[$i]);
        }
    }
    public function henfan(){
        $arr = [
            'a' => 111,
            'b' => '小白'
        ];

        $data[] = $arr;
        $data['c'][] = 'www';
        dump($data);
    }*/
}